﻿using System;
using System.Collections.Generic;

namespace Trade.Journal
{
    public class DealBase:IScore
    {
        public virtual int Sequence { get; set; }

        public string RecordId { get; set; }

        public string Id { get; set; }

        /// <summary>
        /// 类型
        /// 入场 加仓 减仓 离场 
        /// </summary>
        public virtual TradeType TradeType { get; set; }

        /// <summary>
        /// 交易时间
        /// </summary>
        public DateTime Time { get; set; }

        /// <summary>
        /// 价格
        /// </summary>
        public double Price { get; set; }

        /// <summary>
        /// 手数
        /// </summary>
        public double Lots { get; set; }


        /// <summary>
        /// 理由
        /// </summary>
        public List<string> Reasons { get; set; } = new List<string>();


        /// <summary>
        /// 
        /// </summary>
        public List<PhotoInfo> Photos { get; set; }

        /// <summary>
        /// 交易周期
        /// </summary>
        public BarCycle TradeCycle { get; set; } = BarCycles.M5; 

        /// <summary>
        /// 评分
        /// </summary>
        public int Score { get; set; }
    }


    public class OpenDeal : DealBase
    {
        /// <summary>
        /// 开仓方向
        /// </summary>
        public TradeDirection OpenDirection { get; set; }

        /// <summary>
        /// 交易类型
        /// </summary>
        public override TradeType TradeType { get => base.TradeType; set { if (value.HasFlag(TradeType.Open)) base.TradeType = value; } }

        /// <summary>
        /// 实际释放起点
        /// </summary>
        public double RealStart { get; set; }

    }


    public class CloseDeal : DealBase
    {
        public double Profit { get; set; }

        public override TradeType TradeType { get => base.TradeType; set { if (value.HasFlag(TradeType.Close)) base.TradeType = value; } } 

        public CloseType CloseType { get; set; }

        public double Highest { get; set; }

        public double Lowest { get; set; }
    }
}